<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>register</title>
    <link href="bootstrap-3.3.5-dist/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <script src="bootstrap-3.3.5-dist/js/jquery.js"></script>
    <script src="bootstrap-3.3.5-dist/js/bootstrap.js"></script>
    <style>
        #code{
    color:#ffffff;/*字体颜色白色*/
    background-color:#000000;
    font-size:13pt;
    font-family:"华康娃娃体W5";
    padding:5px 10px 10px 15px;
    cursor:pointer;
    }
    </style>
</head>
<body onload="changeImg()">

<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">Brand</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
                <li><a href="#">Link</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Action</a></li>
                        <li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#">One more separated link</a></li>
                    </ul>
                </li>
            </ul>
            <form class="navbar-form navbar-left">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="Search">
                </div>
                <button type="submit" class="btn btn-default">Submit</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Link</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Action</a></li>
                        <li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>

<div class="text-center ">
    <img src="08.jpg" >
</div>
<div style="margin: 0 auto; width: 250px">
<form class="form-horizontal"; style="margin-top: 30px" onsubmit="return check()" action="login.html">
    <div class="form-group">
        <label class="col-sm-3  col-md-5 control-label" for="UserInput">账号</label>
        <div class="col-sm-9 col-md-7">
            <input class="form-control" type="text" id="UserInput" placeholder="请输入账号">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 col-md-5 control-label" for="PasswordInput">密码</label>
        <div class="col-sm-9 col-md-7">
            <input class="form-control" type="text" id="PasswordInput" placeholder="请输入密码">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3  col-md-5 control-label" for="ReaptpasswordInput">重复密码</label>
        <div class="col-sm-9 col-md-7">
            <input class="form-control" type="text" id="ReaptpasswordInput" placeholder="请输入重复密码">
        </div>
    </div>
    <div class="form-group">
        <label class=" col-sm-3  col-md-5 control-label" for="TestInput">验证码</label>
        <div class="col-sm-6 col-md-5">
            <input class="form-control" type="text" id="TestInput" placeholder="请输入验证码">
        </div>
        <div class="col-sm-3 col-md-2"><span id="code" title="看不清，换一张" ></span></div>
    </div>
    <div style="margin:0 auto">
        <button  class="btn btn-primary col-xs-4 col-xs-offset-4 col-md-4 col-md-offset-4 col-sm-4 col-sm-offset-4"  type="submit">注册</button>
    </div>

    <script type="text/javascript">
        var code;//声明一个变量用于存储生成的验证码
        document.getElementById("code").onclick=changeImg;
        function changeImg(){
            //alert("换图片");
            var arrays=new Array(
                    '1','2','3','4','5','6','7','8','9','0',
                    'a','b','c','d','e','f','g','h','i','j',
                    'k','l','m','n','o','p','q','r','s','t',
                    'u','v','w','x','y','z',
                    'A','B','C','D','E','F','G','H','I','J',
                    'K','L','M','N','O','P','Q','R','S','T',
                    'U','V','W','X','Y','Z'
            );
            code='';//重新初始化验证码
            //alert(arrays.length);
            //随机从数组中获取四个元素组成验证码
            for(var i=0;i<4;i++){
                //随机获取一个数组的下标
                var r=parseInt(Math.random()*arrays.length);
                code+=arrays[r];
                //alert(arrays[r]);
            }
            //alert(code);
            document.getElementById('code').innerHTML=code;//将验证码写入指定区域
        }

        //效验验证码(表单被提交时触发)
        function check(){
            //获取用户输入的验证码
            var input_code=document.getElementById('TestInput').value;
            //alert(input_code+"----"+code);
            if(input_code.toLowerCase()==code.toLowerCase())
            {
                alert("注册成功!");
                //验证码正确(表单提交)
                return true;
            }
            alert("请输入正确的验证码!");
            //验证码不正确,表单不允许提交
            return false;
        }
    </script>
</form>
</div>
</body>
</html>